package com.ctjsoft.fileupload.controller;

import com.ctjsoft.fileupload.entity.ReturnMessage;
import com.ctjsoft.fileupload.entity.TBucketServer;
import com.ctjsoft.fileupload.server.TBucketServerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController("bucket")
@Log4j2
@Api(tags = "存储桶控制器")
public class TBucketControlle {

    @Autowired
    TBucketServerService tBucketServerService;

    @PostMapping("deleteBucket")
    @ApiOperation("删除桶")
    /***
     * 1、根据服务名删除对应的桶
     * 2、根据桶ID，删除桶
     * 3、根据桶名称，删除通
     * 注：桶中有文件时，默认不删除,如Enforce参数不为空的情况下强制删除桶及桶中文件
     */
    public ReturnMessage deleteBucket(@RequestParam(value = "serverName", required = false) String serverName, @RequestParam(value = "bucketId", required = false) String bucketId, @RequestParam(value = "bucketName", required = false) String bucketName, @RequestParam(value = "enforce", required = false) boolean enforce) {
        ReturnMessage returnMessage = new ReturnMessage();
        TBucketServer bucketByName = tBucketServerService.getBucketByName(serverName);
        return returnMessage;
    }
}
